package com.ym.utils;

import com.ym.datasource.redis.RedisOperate;
import redis.clients.jedis.Jedis;

import java.util.Iterator;
import java.util.Set;

/**
 * @ClassName RedisManager
 * @Author dhf
 * @Description TODO
 * @Date 2018/10/16 0016 上午 10:35
 * @Version 1.0
 */
public class RedisManager {
    public static int delHeanLines(RedisOperate redisOperate,String key){
        Jedis j = null;
        Long i = 0L;
        try {
            j = redisOperate.getResource();
            Set<String> keys = j.keys(key+":*");
            Iterator<String> it=keys.iterator() ;
            while(it.hasNext()){
                String strKey = it.next();
                System.err.println(strKey);
                i = j.del(strKey);
            }
        }catch (Exception e){
            e.printStackTrace();
            Logger.error(e.getMessage());
            i = -1L;
        }finally {
            redisOperate.returnResource(j);
        }
        return i.intValue();
    }
}
